﻿using System.Web.Mvc;
using System.Web.Routing;

namespace ASPItalia.ModelVirtualCasting.Web.Utils
{
    public class DynamicControllerFactory : DefaultControllerFactory
    {
        public override IController CreateController(RequestContext requestContext, string controllerName)
        {
            var res = base.CreateController(requestContext, controllerName);

            var targetController = res as Controller;
            if (targetController == null)
                return res;

            targetController.ActionInvoker = new ConfigurableActionInvoker();

            return targetController;
        }
    }
}